<?php

namespace app\modules\api\controllers;

use Yii;
use app\modules\api\models\Field;
use yii\data\ActiveDataProvider;
use yii\rest\ActiveController;
use yii\web\NotFoundHttpException;
use yii\web\ServerErrorHttpException;

/**
 * @OA\Tag(
 *   name="Field",
 *   description="字段管理",
 * )
 */
class FieldController extends ActiveController
{
    public $modelClass = 'app\modules\api\models\Field';

    /**
     * @OA\Get(
     *      path="/field",
     *      summary="字段列表",
     *      tags={"Field"},
     *      @OA\Parameter(
     *          description="所在模块",
     *          in="query",
     *          name="module",
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(
     *                      property="field",
     *                      type="array",
     *                      @OA\Items(
     *                          @OA\Property(property="id", type="integer", example="1", description="ID"),
     *                          @OA\Property(property="name", type="string", example="客户编号", description="标识名"),
     *                          @OA\Property(property="type", type="string", example="单行文本", description="字段类型"),
     *                          @OA\Property(property="allowEmpty", type="string", example="否", description="是否必填"),
     *                          @OA\Property(property="status", type="integer", example="1", description="字段显示（ 0：否、1：是 ）"),
     *                          @OA\Property(property="auth", type="integer", example="1", description="字段权限（ 1：读写、2：只读、3：只读密文、4：不可见 ）"),
     *                      ),
     *                  ),
     *                  @OA\Property(
     *                      property="module",
     *                      type="array",
     *                      @OA\Items(
     *                          @OA\Property(property="id", type="integer", example="1", description="ID"),
     *                          @OA\Property(property="name", type="string", example="客户", description="名称"),
     *                      ),
     *                  ),
     *              )
     *          )
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionIndex()
    {
    }

    /**
     * @OA\Post(
     *      path="/field/update",
     *      tags={"Field"},
     *      summary="编辑字段",
     *      @OA\Parameter(
     *          description="字段ID",
     *          in="query",
     *          name="id",
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\RequestBody(
     *          @OA\MediaType(
     *              mediaType="multipart/form-data",
     *              @OA\Schema(
     *                  required={"module", "type", "formType", "name", "isValidate", "isUnique", "isCheck", "isAllowEmpty", "inListShow", "inAddShow", "status", "auth"},
     *                  @OA\Property(property="module", type="integer", enum={1, 2, 3}, description="所在模块（ 1：x、2：xx、3：xxx）"),
     *                  @OA\Property(property="type", type="integer", enum={1, 2}, description="信息类型（ 1：主要信息、2：附加信息）"),
     *                  @OA\Property(
     *                      property="formType",
     *                      type="integer",
     *                      enum={1, 2, 3, 4, 5, 6, 7, 8 ,9, 10},
     *                      description="信息类型（ 1：单行文本、2：多行文本、3：选项、4：日期、5：数字、6：小数（小数点后两位）、7：手机、8：电话、9：邮箱、10：地址）"
     *                  ),
     *                  @OA\Property(property="name", type="string", description="名称"),
     *                  @OA\Property(property="maxLength", type="integer", default="", description="最大长度"),
     *                  @OA\Property(property="defaultValue", type="string", default="", description="默认值"),
     *                  @OA\Property(property="value", type="string", default="", description="值"),
     *                  @OA\Property(property="tips", type="string", default="", description="提示语"),
     *                  @OA\Property(property="isValidate", type="boolean", description="是否验证"),
     *                  @OA\Property(property="isUnique", type="boolean", description="是否唯一"),
     *                  @OA\Property(property="isCheck", type="boolean", description="是否去重"),
     *                  @OA\Property(property="isAllowEmpty", type="boolean", description="是否允许为空"),
     *                  @OA\Property(property="inListShow", type="boolean", description="列表页显示"),
     *                  @OA\Property(property="inAddShow", type="boolean", description="添加页显示"),
     *                  @OA\Property(property="status", type="integer", enum={0, 1}, description="状态（ 0：关闭、1：显示）"),
     *                  @OA\Property(property="auth", type="integer", enum={1, 2, 3, 4}, description="权限（ 1：读写、2：只读、3：只读密文、4：不可见 ）"),
     *                  @OA\Property(property="sort", type="integer", default=0, description="排序"),
     *             )
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionCreate()
    {
    }

    /**
     * @OA\Post(
     *      path="/field/create",
     *      tags={"Field"},
     *      summary="添加字段",
     *      @OA\RequestBody(
     *          @OA\MediaType(
     *              mediaType="multipart/form-data",
     *              @OA\Schema(
     *                  required={"module", "type", "formType", "name", "isValidate", "isUnique", "isCheck", "isAllowEmpty", "inListShow", "inAddShow", "status", "auth"},
     *                  @OA\Property(property="module", type="integer", enum={1, 2, 3}, description="所在模块（ 1：x、2：xx、3：xxx）"),
     *                  @OA\Property(property="type", type="integer", enum={1, 2}, description="信息类型（ 1：主要信息、2：附加信息）"),
     *                  @OA\Property(
     *                      property="formType",
     *                      type="integer",
     *                      enum={1, 2, 3, 4, 5, 6, 7, 8 ,9, 10},
     *                      description="信息类型（ 1：单行文本、2：多行文本、3：选项、4：日期、5：数字、6：小数（小数点后两位）、7：手机、8：电话、9：邮箱、10：地址）"
     *                  ),
     *                  @OA\Property(property="name", type="string", description="名称"),
     *                  @OA\Property(property="maxLength", type="integer", default="", description="最大长度"),
     *                  @OA\Property(property="defaultValue", type="string", default="", description="默认值"),
     *                  @OA\Property(property="value", type="string", default="", description="值"),
     *                  @OA\Property(property="tips", type="string", default="", description="提示语"),
     *                  @OA\Property(property="isValidate", type="boolean", description="是否验证"),
     *                  @OA\Property(property="isUnique", type="boolean", description="是否唯一"),
     *                  @OA\Property(property="isCheck", type="boolean", description="是否去重"),
     *                  @OA\Property(property="isAllowEmpty", type="boolean", description="是否允许为空"),
     *                  @OA\Property(property="inListShow", type="boolean", description="列表页显示"),
     *                  @OA\Property(property="inAddShow", type="boolean", description="添加页显示"),
     *                  @OA\Property(property="status", type="integer", enum={0, 1}, description="状态（ 0：关闭、1：显示）"),
     *                  @OA\Property(property="auth", type="integer", enum={1, 2, 3, 4}, description="权限（ 1：读写、2：只读、3：只读密文、4：不可见 ）"),
     *                  @OA\Property(property="sort", type="integer", default=0, description="排序"),
     *             )
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionUpdate()
    {
    }

    /**
     * @OA\POST(
     *      path="/field/delete",
     *      summary="删除字段",
     *      tags={"Field"},
     *      @OA\Parameter(
     *          description="字段ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionDelete()
    {
    }
}
